function loginn() {
    let telEl = $('.tel')
    let pwEl = $('.pw')
    let yzmEl = $('.w80')
    let btn = $('.btn')
    let err = $('.l_err')
    let TestTel = /^1[3|4|5|7|8][0-9]{9}$/
    let Testpwd = /^(?!bai[0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,20}$/
    let telFlag = false
    let telFlag1 = false
    let telFlag2 = false

    telEl.on('blur', function() {

        let tell = telEl.val()
        TestTel.test(tell);
        if (TestTel.test(tell)) {
            telFlag = true;
            err.html('')
        } else {
            err.html('<div>请输入用户名或者邮箱或者手机号！</div>')
            telFlag = false;
        }
    })

    pwEl.on('blur', function() {

        let pwdd = pwEl.val()
        Testpwd.test(pwdd);
        if (Testpwd.test(pwdd)) {
            telFlag1 = true;
            err.html('')
        } else {
            err.html('<div>请输入密码！</div>')
            telFlag1 = false;
        }
    })


    yzmEl.on('blur', function() {
        let yanzhengnumber = yzmEl.val()
        var str = "8LA6"
        if (yanzhengnumber === str) {
            $('.ico ').addClass('y_suc')
            $('.ico ').removeClass('y_err')
            telFlag2 = true
            err.html('')
        } else {
            $('.ico ').addClass('y_err')
            $('.ico ').removeClass('y_suc')
            telFlag2 = false
            err.html('<div>请输入验证码！</div>')
        }
    })

    function log() {
        let pw = $(".pw").val()
        let tel = $(".tel").val()
        console.log(pw, tel);
        console.log(telFlag, telFlag1, telFlag2);
        if (!(telFlag && telFlag1 && telFlag2)) {
            return;
        }
        console.log('通过');
        $.ajax({
            type: 'get',
            url: 'http://localhost:3000/register/login',
            data: {
                tel: tel,
                pw: pw
            },
            dataType: 'json',
            success: function(data) {
                if (data.code == 1) {
                    alert('登录成功')
                    location.href = './index.html';

                    $.cookie(`${tel}`, `${pw}`, {
                        expires: 7
                    })
                } else if (data.code == 2) {
                    alert('密码错误')
                } else if (data.code == 3) {
                    alert('用户未注册')
                }
            }
        })
    }
    $('.btn').on('click', log)

}
loginn()